# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=appstream-glib
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.8.3
pkgrel=1
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64')
pkgdesc="Objects and methods for reading and writing AppStream metadata (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-gdk-pixbuf2"
         "${MINGW_PACKAGE_PREFIX}-glib2"
         "${MINGW_PACKAGE_PREFIX}-gtk3"
         "${MINGW_PACKAGE_PREFIX}-json-glib"
         "${MINGW_PACKAGE_PREFIX}-libyaml"
         "${MINGW_PACKAGE_PREFIX}-curl"
         "${MINGW_PACKAGE_PREFIX}-libarchive")
makedepends=("${MINGW_PACKAGE_PREFIX}-gobject-introspection"
             "${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-pkgconf"
             "${MINGW_PACKAGE_PREFIX}-vala"
             "${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-gperf")
license=('spdx:LGPL-2.1-or-later')
url="https://people.freedesktop.org/~hughsient/appstream-glib/"
source=("https://github.com/hughsie/appstream-glib/archive/appstream_glib_${pkgver//./_}.tar.gz")
sha256sums=('15ad7690b0132d883bd066699a7b55f6cef4c0f266d18d781ce5d8112fb4ee63')

prepare() {
  cd "${srcdir}"/${_realname}-${_realname//-/_}_${pkgver//./_}

}

build() {
  mkdir -p build-${MSYSTEM} && cd build-${MSYSTEM}

  MSYS2_ARG_CONV_EXCL="--prefix=" \
  ${MINGW_PREFIX}/bin/meson.exe setup \
    --prefix=${MINGW_PREFIX} \
    --buildtype=plain \
    --wrap-mode=nodownload \
    --auto-features=enabled \
    --default-library=both \
    -Dintrospection=true \
    -Dgtk-doc=true \
    -Dman=true \
    -Dfonts=true \
    -Dalpm=false \
    -Drpm=false \
    -Ddep11=false \
    -Dbuilder=false \
    "../${_realname}-${_realname//-/_}_${pkgver//./_}"

  ${MINGW_PREFIX}/bin/meson.exe compile
}

package() {
  cd build-${MSYSTEM}
  DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/meson.exe install

  install -Dm644 "${srcdir}/${_realname}-${_realname//-/_}_${pkgver//./_}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
